import Axios from "axios"

const URL="https://application.5gzglt.com/v1.0/";
const URLText = "https://test.mingchetech.com/v1.0/";
const isHttp = false;
export const ip ="application.5gzglt.com";
export const brandId="188"

export function request(config){
    const instance = Axios.create({
        baseURL:isHttp?URL:URLText,
        timeout: 5000
    })
    // 请求拦截器
    instance.interceptors.request.use(config=>{
        if(localStorage.getItem("token")!=null){
            config.headers["authToken"]=localStorage.getItem("token")
        }
        return config
    },err => {
        console.log("请求失败:"+err);
    });
    
    // 响应拦截器
    instance.interceptors.response.use(res=>{
        return res.data
    },err=>{
        console.log("响应失败:"+err);
    });

    return instance(config);
}
